<?php
namespace App\Admin\Models;
use Common\BaseModel;
class HomeCarousel extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function initialize()
    {
        parent::initialize();
        $this->setSource('view_home_carousel');
    }

    public function find_list($ids=''){
        $condition="";
        if(!empty($ids)){
            $condition = "id in($ids)";
        }
        $list = $this::find(array(
            $condition
        ));
        return $list;
    }



    public function get_list($params=[]){
        $where = '';
        if(isset($params['name']) && !empty($params['name'])){
            $where = "name like '%{$params['name']}%'";
        }
        return $this->find(array(
                $where,
                'order' => 'id desc'
            )
        );
    }


    /**
     * @param $id
     * @return array
     */
    public function find_by_id($id){
        if(empty($id)){
            return [];
        }
        $cate_info = $this->findFirstById($id);
        if($cate_info){
            return $cate_info->toarray();
        }else{
            return [];
        }
    }


    public function find_by_id_obj($id){
        return $this->findFirstById($id);
    }


    public function save_params($params){
        return $this::save($params);
    }


}
